window.addEventListener("load", function(){
	var theButton;
	var UIItemProperties = {
		disabled: true,
		title: "Nagios Checker",
		icon: "nc-button.png",
		onclick: function() {
			var tab = opera.extension.tabs.getFocused();
			if(tab) {
				tab.postMessage('go');
			}
		},
	}
	theButton = opera.contexts.toolbar.createItem(UIItemProperties);
	opera.contexts.toolbar.addItem(theButton);
	function enableButton() {
		var tab = opera.extension.tabs.getFocused();
		if(tab) {
			theButton.disabled = false;
		} else {
			theButton.disabled = true;
		}
	}
	opera.extension.onconnect = enableButton;
	opera.extension.tabs.onfocus = enableButton;
	opera.extension.tabs.onblur = enableButton;
}, false);

